package com.ccsu.mymarket.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
//开启了事务
@EnableTransactionManagement
@MapperScan("com.ccsu.mymarket.dao")
public class MybatisPlusConfig {
	// Indicates that a method produces a bean to be managed by the Spring container
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
    	//1.定义Mp拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
      //2.添加具体的拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }


    /**
     * 对 resultType="java.util.Map"的查询，设置map键值对能自动将下划线转驼峰式
    @Bean
    public ConfigurationCustomizer configurationCustomizer() {
        return i -> i.setObjectWrapperFactory(new MybatisMapWrapperFactory());
    }
     */
}
